﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class eduquestion : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    //重置
    protected void btnnewq_Click(object sender, EventArgs e)
    {
        PageRebush();
    }
   
    //提交数据库
    protected void btneduquestion_Click(object sender, EventArgs e)
    {
        SqlConnection objConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["smsConnectionString"].ConnectionString);
        SqlDataAdapter adapter = new SqlDataAdapter("select * from QuestionInfo where IsDeleted<>1", objConnection);
        SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
        DataSet ds = new DataSet();
        adapter.Fill(ds, "QuestionInfo");
        DataTable dt = ds.Tables["QuestionInfo"];


        DataRow row = dt.NewRow();
        row["QuestionDes"] = this.txtqproblem.Text;
        row["CourDocumentID"] = Request.QueryString["FileID"];
        row["Answer1"] = this.txtqanswerA.Text;
        row["Answer2"] = this.txtqanswerB.Text;
        row["Answer3"] = this.txtqanswerC.Text;
        row["Answer4"] = this.txtqanswerD.Text;
        row["RightAnswer"] = this.RadioButtonListaq.SelectedItem.Text;
        row["IsDeleted"] = false;
        dt.Rows.Add(row);

        adapter.Update(dt);

        Response.Redirect("~/eduExamquestion.aspx?FileID=" + Request.QueryString["FileID"] + "");

        //PageRebush();
    }

    //页面刷新
    public void PageRebush()
    {
        this.txtqproblem.Text = "";
        this.txtqanswerA.Text = "";
        this.txtqanswerB.Text = "";
        this.txtqanswerC.Text="";
        this.txtqanswerD.Text="";
        this.RadioButtonListaq.SelectedIndex = -1;
    }
}
